# -*- coding: utf-8 -*-
from datetime import timedelta
# 引入依赖
from jms.dm.prescription.dm_prescription_reach_details_dt import jms_dm__dm_prescription_reach_details_dt
from jms.dm.dm_whole_decide_duty_pres_base_dt import jms_dm__dm_whole_decide_duty_pres_base_dt
from jms.dwd.tab.dwd_tab_reback_transfer_express_base_dt import jms_dwd__dwd_tab_reback_transfer_express_base_dt
from jms.dwd.sqs.dwd_sqs_registration_problem_piece_base_dt import jms_dwd__dwd_sqs_registration_problem_piece_base_dt
from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
from jms.dim.sqs.dim_abnormal_event_report_base import jms_dim__dim_abnormal_event_report_base
from jms.dim.sqs.dim_arbitration_configuration_base import jms_dim__dim_arbitration_configuration_base
from jms.dim.dim_yl_oms_order_interceptor_base_dt import jms_dim__dim_yl_oms_order_interceptor_base_dt
from jms.dwd.tab.dwd_tab_barscan_transfer_mail_base_dt import jms_dwd__dwd_tab_barscan_transfer_mail_base_dt
from jms.dwd.oms.dwd_yl_oms_order_mark_expand_base_dt import jms_dwd__dwd_yl_oms_order_mark_expand_base_dt
from jms.dwd.sqs.dwd_problem_service_record_base_dt import jms_dwd__dwd_problem_service_record_base_dt

from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dm__dm_already_sign_no_reach_details_dt = SparkSqlOperator(
    task_id='jms_dm__dm_already_sign_no_reach_details_dt',
    email=['jokic.wang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    pool_slots=3,
    master='yarn',
    name='jms_dm__dm_already_sign_no_reach_details_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dm/dm_already_sign_no_reach_details_dt/execute.hql',
    driver_memory='14G',
    executor_memory='10G',
    executor_cores=2,
    num_executors=12,
    yarn_queue='pro',
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 15,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead': '2G',
          'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=2'
          },
    # hiveconf={'hive.exec.dynamic.partition': 'true',  # 开启动态分区
    #           'hive.exec.dynamic.partition.mode': 'nonstrict',  # 动态分区模式非严格
    #           },
    execution_timeout=timedelta(minutes=40)
)

jms_dm__dm_already_sign_no_reach_details_dt << [jms_dm__dm_prescription_reach_details_dt,
                                                jms_dwd__dwd_tab_barscan_transfer_mail_base_dt,
                                                jms_dm__dm_whole_decide_duty_pres_base_dt,
                                                jms_dwd__dwd_tab_reback_transfer_express_base_dt,
                                                jms_dwd__dwd_sqs_registration_problem_piece_base_dt,
                                                jms_dim__dim_network_whole_massage,
                                                jms_dim__dim_abnormal_event_report_base,
                                                jms_dim__dim_arbitration_configuration_base,
                                                jms_dim__dim_yl_oms_order_interceptor_base_dt,
                                                jms_dwd__dwd_yl_oms_order_mark_expand_base_dt,
                                                jms_dwd__dwd_problem_service_record_base_dt
                                                ]
